package avicit.cbb.businessclass.funcoperationset.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import avicit.cbb.funcoperationset.service.FuncOperationSetIntfsService;
import avicit.platform6.core.jdbc.JdbcAvicit;

/**
 * <p>金航数码科技有限责任公司</p>
 * <p>作者：吴瑾</p>
 * <p>邮箱：wujin01@avicit.com</p>
 * <p>创建时间： 2014-11-26 下午2:23:16 </p>
 * <p>类说明：功能操作定义接口</p>
 * <p>修改记录： </p>
 */
@Service
public class FuncOperationSetIntfsServiceImpl implements FuncOperationSetIntfsService {

	@Resource
	JdbcAvicit jdbcAvicit;

	/**
	 * 获取指定菜单Id下所定义的操作信息
	 * @author 吴瑾
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param funcId
	 * @return
	 * @throws Exception List<Map<String,Object>>
	 * @throws
	 */
	@Override
	public List<Map<String, Object>> getFuncOperationSetInfoByIntfs(String orgId, String deptId, String sysId, String funcId) throws Exception {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("select t.* ");
		sbSql.append("  from cbb_func_operation_set t ");
		sbSql.append(" where t.func_menu_id = '" + funcId + "' ");
		sbSql.append("   and t.SYS_ID = '" + sysId + "' ");
		sbSql.append("   and t.ORG_ID ='" + orgId + "'");
		List<Map<String, Object>> list = this.jdbcAvicit.getJdbcTemplate().queryForList(sbSql.toString());
		return list;
	}

	/**
	 * 获取菜单下所有的按钮信息
	 * @author 张坚 
	 * @param orgId
	 * @param deptId
	 * @param sysId
	 * @param menuCode
	 * @return List<Map<String,Object>>
	 * @throws Exception 
	 */
	@Override
	public List<Map<String, Object>> getFuncOperationSetInfoByMenuCode(String orgId, String deptId, String sysId, String menuCode) throws Exception {
		StringBuffer sbSql = new StringBuffer();
		sbSql.append("SELECT CFOS.* ");
		sbSql.append("  FROM CBB_FUNC_OPERATION_SET CFOS ");
		sbSql.append(" INNER JOIN SYS_MENU SM ");
		sbSql.append("    ON CFOS.FUNC_MENU_ID = SM.ID ");
		sbSql.append(" WHERE CFOS.ORG_ID = '" + orgId + "' ");
		// sbSql.append("   AND CFOS.DEPT_ID = '"+deptId+"' ");
		sbSql.append("   AND CFOS.SYS_ID = '" + sysId + "' ");
		sbSql.append("   AND SM.CODE = '" + menuCode + "'");
		return this.jdbcAvicit.queryForMap(sbSql.toString(), null);
	}

}
